/*
 * Default Treatment Record Info
 */
/*
 * DefaultTreatmentRecordInfo.java
 * 
 * @version 1.0, March 15, 2011
 * CS 2340 Team 10: Cyberdyne Systems
 */
package edu.gatech.oad.cyberdoc.domain;

import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * Represents the "default" TreatmentRecordInfo. This class is used to prevent
 * checking for null throughout the TreatmentRecordInfo class.
 * 
 * @author John Girata
 * @version 1.0, March 15, 2011
 */
public class DefaultTreatmentRecordInfo extends TreatmentRecordInfo {

	/**
	 * Returns null (the default value) if this is a legal field, or an
	 * exception otherwise.
	 * 
	 * @param key
	 *            The name of the field to set
	 * @return null
	 * @throws NoSuchElementException
	 *             If this field name is not a legal name
	 */
	@Override
	public Object getField(String key) throws NoSuchElementException {
		if (!KEYS.contains(key)) {
			throw new NoSuchElementException("The element " + key
					+ " does not exist.");
		}

		return null;
	}

	/**
	 * Returns a Map object mapping each fields to its default value.
	 * 
	 * @return All legal keys mapped to their default value
	 */
	@Override
	protected Map<String, Object> getShallowFieldsCopy() {
		final Map<String, Object> defaults = new HashMap<String, Object>();

		for (String key : TreatmentRecordInfo.KEYS) {
			defaults.put(key, null);
		}

		return defaults;
	}
}
